﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using System.Windows.Forms;

namespace CXJ.BLL.Demo
{
    public class tbCartoon : BaseBLL
    {
        private CXJ.Interface.IBaseEntity baseEntity;
        public override CXJ.Interface.IBaseEntity X_BaseEntity
        {
            get
            {
                if (baseEntity == null)
                {
                    baseEntity = Libiary.DataFactory.CreateEntity(typeof(Model.Demo.tbCartoonEntity));
                }
                return baseEntity;
            }
        }
        public void BindDataGridView(DataGridView dv)
        {
            if (dv == null) return;
            DataSet tempDataSet = this.Select();
            if (tempDataSet != null && tempDataSet.Tables != null && tempDataSet.Tables.Count > 0)
            {
                dv.DataSource = tempDataSet.Tables[0];
            }
        }
        public void Select(Form form, DataGridView dv)
        {
            CXJ.Interface.IBaseEntity entity = (CXJ.Interface.IBaseEntity)X_BaseEntity.Clone();
            UIProcess.Instance.SetEntityValue(form, entity, "S_");
            DataSet tempDataSet = this.Select(entity);
            if (tempDataSet != null && tempDataSet.Tables != null && tempDataSet.Tables.Count > 0)
            {
                dv.DataSource = tempDataSet.Tables[0];
            }
        }
        public void SelectBind(Form form, DataGridView dv)
        {
            CXJ.Interface.IBaseEntity entity = (CXJ.Interface.IBaseEntity)X_BaseEntity.Clone();
            UIProcess.Instance.SetEntityValue(form, entity, "S_");
            List<CXJ.Interface.IBaseEntity> lists = this.SelectEntity(entity);
            dv.DataSource = lists;
        }

        public DataSet SelectForOperate(CXJ.Interface.IBaseEntity baseEntity)
        {
            return this.Select(baseEntity);
        }

        private List<CXJ.Interface.IBaseEntity> SelectEntity()
        {
            return X_DataOperater.GetEntityList();
        }
        private List<CXJ.Interface.IBaseEntity> SelectEntity(CXJ.Interface.IBaseEntity baseEntity)
        {
            return X_DataOperater.GetEntityList(baseEntity);
        }

        private DataSet Select()
        {
            return X_DataOperater.Select();
        }
        private DataSet Select(CXJ.Interface.IBaseEntity baseEntity)
        {
            return X_DataOperater.Select(baseEntity);
        }
    }
}
